package com.zb.dao.ext.common;

import org.springframework.stereotype.Repository;

import com.zb.dao.base.OmsCommonDao;
import com.zb.entity.exception.OmsDaoException;
import com.zb.entity.station.OmsStationCollect;

/**
 * 站点收集表单
 * 
 * @author xielongfei
 * 
 */
@Repository
public class OmsStationCollectDao extends OmsCommonDao<OmsStationCollect> 
{
	public static final String COLLECT_STATION = "insert into oms_station(station_id,station_name,oper_merchant_id,district_code,circle,coordtype,coordinate,parking_type,parking_addr,photo,total_charger,establish_time,station_type,is_allow_open,address,current_state,direct_num,alternate_num,tel_no,is_rent,describes,entity_type,entity_id,valid_flag,create_time,create_oper_id,update_time,update_oper_id) "
			+ "select ? as station_id,station_name,oper_merchant_id,district_code,circle,coordtype,coordinate,parking_type,parking_addr,photo,total_charger,establish_time,station_type,is_allow_open,address,current_state,direct_num,alternate_num,tel_no,0 as is_rent,describes,"
			+ "? as entity_type, ? as entity_id,valid_flag,now() as create_time,? as create_oper_id, now() as update_time, ? as update_oper_id from oms_station_collect where station_id = ? ";
	public static final String COLLECT_STATION_EXTERNAL = "insert into oms_station_external "
			+ "(station_id,org_station_id,source_id,station_name,oper_merchant_id,district_code,circle,coordtype,coordinate,parking_type,parking_addr,photo,total_charger,establish_time,station_type,is_allow_open,address,current_state,direct_num,alternate_num,tel_no,describes,park_fee,charger_fee,pay_manner,verify_flag,discover_user_id,valid_flag) "
			+ "select ? as station_id,org_station_id,source_id,station_name,oper_merchant_id,district_code,circle,coordtype,coordinate,parking_type,parking_addr,photo,total_charger,establish_time,station_type,is_allow_open,address,current_state,direct_num,alternate_num,tel_no,describes,park_fee,charger_fee,pay_manner,0 as verify_flag,"
			+ " ? as discover_user_id,1 as valid_flag from oms_station_collect where station_id = ? ";
	public void addOmsStationByCollect(String collectId,String stationId,String entityId,String entityType,String userId) throws OmsDaoException
	{
		try
		{
			this.getJdbcTemplate().update(COLLECT_STATION,stationId, entityType,entityId,userId,userId,collectId);
		}
		catch(Exception e)
		{
			throw new OmsDaoException();
		}
	}
	
	public void addOmsStationExternalByCollect(String collectId,String stationId,String userId) throws OmsDaoException
	{
		try
		{
			this.getJdbcTemplate().update(COLLECT_STATION_EXTERNAL,stationId, userId,collectId);
		}
		catch(Exception e)
		{
			throw new OmsDaoException();
		}
	}
	
}
